package com.xr.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.xr.constant.MessageConstant;
import com.xr.pojo.SetMeal;
import com.xr.result.Result;
import com.xr.service.SetMealService;
import com.xr.utils.QiNiuUtils;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("setMeal")
public class SetMealController {
    //远程调用
    @Reference
    private SetMealService setMealService;

    @RequestMapping("/getSetmeal")
    public Result findAll(){

        List<SetMeal> all = setMealService.findAll();
        for (SetMeal s:all) {
            s.setImg(QiNiuUtils.DOMAIN+s.getImg());
        }
        return new Result(true, MessageConstant.QUERY_SETMEAL_SUCCESS,all);

    }

    @RequestMapping("/queryById")
    public Result queryById(Integer id){

        SetMeal setmeal = setMealService.QueryById(id);
//        SetMeal setmeal = setMealService.QueryById2(id);
//        SetMeal setmeal = setMealService.QueryById3(id);

        setmeal.setImg(QiNiuUtils.DOMAIN+setmeal.getImg());
        return new Result(true, MessageConstant.QUERY_SETMEAL_SUCCESS,setmeal);

    }

    @RequestMapping("/queryById2")
    public Result queryById2(Integer id){

        SetMeal setmeal = setMealService.queryById(id);
//        SetMeal setmeal = setMealService.QueryById2(id);
//        SetMeal setmeal = setMealService.QueryById3(id);

        setmeal.setImg(QiNiuUtils.DOMAIN+setmeal.getImg());
        return new Result(true, MessageConstant.QUERY_SETMEAL_SUCCESS,setmeal);

    }

}
